<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // Function.prototype.myCall = function (context = window) {
    //   // console.log(context); // foo
    //   context.fn = this;
    //   console.log(this); // bar:function
    //   var arr = [...arguments];
    //   arr.shift();
    //   let result = context.fn(...arr);
    //   delete context.fn;
    //   return result;
    // }
    // 测试一下
    var foo = {
      value: 1
    };
    Function.prototype.myCall=function(ctx,...arr){
      console.log(ctx);
      ctx.fn=this
      let result =ctx.fn(...arr)
      delete ctx.fn
      return result
    }
    function bar(name, age) {
      console.log(name)
      console.log(age)
      console.log(this.value);
    }
    bar.myCall(foo, 'kevin', 18);
    // kevin
    // 18
    // 1
    let obj1={h:23,f:45}
    const obj2=obj1
    obj1.f=00000001
    console.log('obj',obj1,obj2);
  </script>
</body>

</html>